using System;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using Random = UnityEngine.Random;


public class RandomText : MonoBehaviour
{
    //提示的显示的文本
    public Text randomText;

    //文本输入框
    public InputField inputField;

    //一个输入的文字的存储器
    private string inputText;
    


    //一些静态变量
    public  int count=1;
    public static int num1=0;

    
    void Start()
    {
        inputText = inputField.text;
        
    }

    public void TestButton()
    {
        AudioManage.instance.PlayButtonAudio();
        inputField.text = "";
        count++;
        if (count == 67)
        {
            count = 1;
        }

        num1++;
        print("切换里面num为"+num1.ToString());
        
        string filePath = "Assets/text/"+count.ToString()+".txt";
        
        StreamReader reader = new StreamReader(filePath);
        string poem = reader.ReadToEnd();
        reader.Close();
        
        string[] lines = poem.Split('\n');
        print(lines.Length);
        string randomLine = lines[Random.Range(0, lines.Length)];
        randomText.text = randomLine;

    }

}
